var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/help/service.ts
var service_exports = {};
__export(service_exports, {
  addCommonData: () => addCommonData,
  addRecentlyData: () => addRecentlyData,
  deleteCommonData: () => deleteCommonData,
  getActiveTabKey: () => getActiveTabKey,
  getCommonList: () => getCommonList,
  getHelpInfo: () => getHelpInfo,
  getHelpList: () => getHelpList,
  getRecentlyList: () => getRecentlyList,
  getSelectedData: () => getSelectedData,
  getTreeList: () => getTreeList,
  saveActiveTabKey: () => saveActiveTabKey
});
module.exports = __toCommonJS(service_exports);
var import_functionalComponent = require("../../functionalComponent");
var import_util = require("../../util");
async function saveActiveTabKey({ helpId, activeTabKey }) {
  return;
}
async function getActiveTabKey({ helpId }) {
  return void 0;
}
async function getHelpInfo({ helpId }) {
  if (!helpId) {
    return {};
  }
  try {
    if (import_util.iup.isFunction(helpId)) {
      helpId = await helpId();
    }
    if ((0, import_util.hasServiceAdapter)("commonHelp", "getHelpInfo")) {
      return await (0, import_util.execServiceAdapter)("commonHelp", "getHelpInfo", { helpId });
    }
    const { code, data } = await import_util.iup.request.get({
      url: `baseservice/comhelp/getComHelpInfo?helpId=${helpId}`
    });
    if (code === 0) {
      return {
        valueField: data.codeField,
        labelField: data.nameField,
        userCodeField: data.userCodeField,
        helpTitle: data.title,
        columns: data.columns.map((c) => ({ ...c, flex: 1, tooltip: true })),
        showTree: data.showTree === 1,
        showList: data.showList ?? data.showTree !== 1,
        helpId
      };
    } else {
      return { helpId };
    }
  } catch {
    return {};
  }
}
async function getHelpList({
  helpId,
  keyword = "",
  // querysearch,
  pageIndex,
  pageSize,
  clientSqlFilter,
  infoRightUIContainerID
}) {
  const data = {
    pageIndex,
    inputKey: keyword,
    pageSize
  };
  if (!helpId) {
    return {
      record: [],
      total: 0
    };
  }
  if (clientSqlFilter) {
    import_util.iup.debug({ msg: clientSqlFilter });
    if (import_util.iup.isObject(clientSqlFilter)) {
      data.clientJsonFilter = clientSqlFilter;
    } else {
      data.clientSqlFilter = import_util.iup.CryptoJS.encode(clientSqlFilter);
    }
  }
  if (infoRightUIContainerID) {
    data.UIContainerID = infoRightUIContainerID;
  }
  try {
    if (import_util.iup.isFunction(helpId)) {
      helpId = await helpId();
    }
    if ((0, import_util.hasServiceAdapter)("commonHelp", "getHelpList")) {
      return await (0, import_util.execServiceAdapter)("commonHelp", "getHelpList", { ...data, helpId });
    }
    const {
      code,
      data: { list, total },
      message: msg
    } = await import_util.iup.request.body({
      url: `baseservice/comhelp/getComHelpList`,
      data: {
        ...data,
        helpId
      }
    });
    if (code !== 0) {
      msg && console.error(msg);
      return {
        record: [],
        total: 0
      };
    }
    return {
      record: list,
      total
    };
  } catch (e) {
    console.error(e);
    return {
      record: [],
      total: 0
    };
  }
}
async function getTreeList({ helpId, clientSqlFilter }) {
  const params = {
    node: "root"
  };
  if (clientSqlFilter) {
    if (import_util.iup.isObject(clientSqlFilter)) {
      params.clientJsonFilter = clientSqlFilter;
    } else {
      params.clientSqlFilter = import_util.iup.CryptoJS.encode(clientSqlFilter);
    }
  }
  if (import_util.iup.isFunction(helpId)) {
    helpId = await helpId();
  }
  if ((0, import_util.hasServiceAdapter)("commonHelp", "getTreeList")) {
    return await (0, import_util.execServiceAdapter)("commonHelp", "getTreeList", { ...params, helpId });
  }
  const {
    code,
    data,
    message: msg
  } = await import_util.iup.request.body({
    url: `baseservice/comhelp/getComHelpTreeList`,
    data: {
      ...params,
      helpId
    }
  });
  if (code === 0) {
    return data;
  }
  msg && import_functionalComponent.message.error(msg);
  return [];
}
async function getSelectedData({ helpId, codes }) {
  try {
    if (import_util.iup.isFunction(helpId)) {
      helpId = await helpId();
    }
    if ((0, import_util.hasServiceAdapter)("commonHelp", "getSelectedData")) {
      return await (0, import_util.execServiceAdapter)("commonHelp", "getSelectedData", { codes, helpId });
    }
    const { data } = await import_util.iup.request.get({
      url: `baseservice/comhelp/getSelectedData`,
      data: {
        helpId,
        codes
      },
      skipError: true
    });
    return data || [];
  } catch (e) {
    return [];
  }
}
async function getCommonList({ helpId, pageIndex, pageSize, clientSqlFilter, infoRightUIContainerID }) {
  const data = {
    pageIndex,
    pageSize
  };
  if (clientSqlFilter) {
    import_util.iup.debug({ msg: clientSqlFilter });
    if (import_util.iup.isObject(clientSqlFilter)) {
      data.clientJsonFilter = clientSqlFilter;
    } else {
      data.clientSqlFilter = import_util.iup.CryptoJS.encode(clientSqlFilter);
    }
  }
  if (infoRightUIContainerID) {
    data.UIContainerID = infoRightUIContainerID;
  }
  if (import_util.iup.isFunction(helpId)) {
    helpId = await helpId();
  }
  if ((0, import_util.hasServiceAdapter)("commonHelp", "getCommonList")) {
    return await (0, import_util.execServiceAdapter)("commonHelp", "getCommonList", { ...data, helpId });
  }
  const {
    code,
    data: { list = [], total = 0 } = {},
    message: msg
  } = await import_util.iup.request.body({
    url: `baseservice/comhelp/getComHelpHotDataList`,
    data: {
      ...data,
      helpId
    }
  });
  if (code === 0) {
    return {
      record: list,
      total
    };
  }
  msg && import_functionalComponent.message.error(msg);
  return { record: [], total: 0 };
}
async function addCommonData({ helpId, codeValue }) {
  if (import_util.iup.isFunction(helpId)) {
    helpId = await helpId();
  }
  if ((0, import_util.hasServiceAdapter)("commonHelp", "addCommonData")) {
    return await (0, import_util.execServiceAdapter)("commonHelp", "addCommonData", { keyValue: codeValue, helpId });
  }
  const result = await import_util.iup.request.post({
    url: `baseservice/comhelp/saveComHelpHotData`,
    data: { helpId, keyValue: codeValue }
  });
  if (result.code === 0) {
    return true;
  } else if (result.message) {
    import_functionalComponent.message.error(result.message);
  }
  return false;
}
async function deleteCommonData({ helpId, codeValue }) {
  if (import_util.iup.isFunction(helpId)) {
    helpId = await helpId();
  }
  if ((0, import_util.hasServiceAdapter)("commonHelp", "deleteCommonData")) {
    return await (0, import_util.execServiceAdapter)("commonHelp", "deleteCommonData", { keyValue: codeValue, helpId });
  }
  const result = await import_util.iup.request.post({
    url: `baseservice/comhelp/deleteHotData`,
    data: { helpId, keyValue: codeValue }
  });
  if (result.code === 0) {
    return true;
  } else if (result.message) {
    import_functionalComponent.message.error(result.message);
  }
  return false;
}
async function getRecentlyList({ helpId, pageIndex, pageSize, clientSqlFilter, infoRightUIContainerID }) {
  return { record: [], total: 0 };
}
async function addRecentlyData({ helpId, codeValue }) {
  if (!codeValue || !helpId) {
    return true;
  }
  return true;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  addCommonData,
  addRecentlyData,
  deleteCommonData,
  getActiveTabKey,
  getCommonList,
  getHelpInfo,
  getHelpList,
  getRecentlyList,
  getSelectedData,
  getTreeList,
  saveActiveTabKey
});
